<template>
    <div id="home">
        <h2>{{msg}}</h2>
        <!-- 非父子组件之间传值演示 -->
        <button @click="emitHome()">给Home组件广播数据</button>
 
    </div>
</template>

<script>
import VueEvent from '../model/vueEvent.js'

export default {

    data(){
        return{
            msg:'我是一个News组件'
        }
    },
    methods:{
       emitHome(){
           VueEvent.$emit('to-home',this.msg);
       }
    },
    components:{
       
    },
    mounted(){
        VueEvent.$on('to-news',function(data){
            console.log(data);
        })
    }
}
</script>

